
local icon1 = class.panel.create([[ReplaceableTextures\CommandButtons\BTNAcolyte.blp]],0,0,64,64)
local icon2 = class.button.create([[ReplaceableTextures\CommandButtons\BTNAcolyte.blp]],1250,780,64,64)
icon2.title = icon2:add_text('孤岛商人',-10,icon2.h,icon2.w+20,20,12,5)
icon2:child_builder {
    parent = icon2,
    type = 'model',
    model = [[UI\Feedback\Autocast\UI-ModalButtonOn.mdl]],
    x = 4,
    y = 2,
    scales = {icon2.w / 94,icon2.h / 70},
    show_flag = true,
}

icon1:hide()
icon2:hide()

--动画结束显示按钮
function icon1:move_animation_finish()
    icon1:hide()
    icon2:show()
end

--点击按钮选择商店
function icon2:on_button_clicked()
    icon2:hide()
    if icon2.unit then
        jass.ClearSelection()
		jass.SelectUnit(icon2.unit.handle, true)
    end
end


ac.game:event '黑市刷新'(function(_,player,unit)
    if player:is_self() then
        icon1:show()
        icon1:set_real_position((1920-icon1.w)/2,650)
        ac.wait(500,function()
            icon1:move_animation({icon2.x,icon2.y},1.5,'线性')
        end)
        icon2:hide()
        icon2.unit = unit
        icon2.title:set_text(unit:get_name())
    end
end)




local icon1 = class.panel.create([[ReplaceableTextures\CommandButtons\BTNMedivh.blp]],0,0,64,64)
local icon2 = class.button.create([[ReplaceableTextures\CommandButtons\BTNMedivh.blp]],1180,780,64,64)
icon2.title = icon2:add_text('随机事件',-10,icon2.h,icon2.w+20,20,12,5)
icon2:child_builder {
    parent = icon2,
    type = 'model',
    model = [[UI\Feedback\Autocast\UI-ModalButtonOn.mdl]],
    x = 4,
    y = 2,
    scales = {icon2.w / 94,icon2.h / 70},
    show_flag = true,
}

icon1:hide()
icon2:hide()

--动画结束显示按钮
function icon1:move_animation_finish()
    icon1:hide()
    icon2:show()
end

--点击按钮选择商店
function icon2:on_button_clicked()
    icon2:hide()
    if icon2.unit then
        jass.ClearSelection()
		jass.SelectUnit(icon2.unit.handle, true)
    end
end


ac.game:event '随机事件'(function(_,player,unit)
    if player:is_self() then
        icon1:show()
        icon1:set_real_position((1920-icon1.w)/2,650)
        ac.wait(500,function()
            icon1:move_animation({icon2.x,icon2.y},1.5,'线性')
        end)
        icon2:hide()
        icon2.unit = unit
        icon2.title:set_text(unit:get_name())
    end
end)
